import { mapState, mapActions } from 'vuex'

export const commonMixin = {
  computed:{
  },
  data() {
    return {
	}
  },
  filters: {
  },
  computed:{
  	...mapState('user', ['token'])
  },
  onLoad(){
	 
  },
  methods: {
	  isLogin(){
		  return this.token != null && this.token != undefined && this.token != '';
	  },
	  navTo(url, params, auth){
		  if(auth && !this.token){
			  uni.$u.route('/pages/login');
			  return;
		  }
		  uni.$u.route(url, params);
	  },
	  back(){
		  uni.navigateBack({})
	  }
  }
}





export const authMixin = {
  computed:{
  	...mapState('user', ['token'])
  },
  data() {
    return {
	}
  },
  onShow(){
	  if(!this.token){
		  uni.$u.route('/pages/login');
	  }
  },
  methods: {
  }
}